package mark;

import android.content.res.Resources;
import android.os.Build;

/**
 * 创建时间：2018年02月11日17:51 <br>
 * 作者：fuchaoyang <br>
 * 描述：
 */

public class ImmersiveUtil {
  public static final boolean IMMERSIVE = true;
  private static int sStatusBarHeight = -1;

  public ImmersiveUtil() {
  }

  public static int getStatusBarHeightIfNeeded() {
    if (sStatusBarHeight != -1) {
      return sStatusBarHeight;
    } else {
      try {
        sStatusBarHeight = Resources.getSystem()
          .getDimensionPixelSize(
            Resources.getSystem().getIdentifier("status_bar_height", "dimen", "android"));
      } catch (Throwable var1) {
        sStatusBarHeight = dip2px(25.0F);
      }

      if (sStatusBarHeight <= 0) {
        sStatusBarHeight = dip2px(25.0F);
      }

      return sStatusBarHeight;
    }
  }

  private static int dip2px(float dpValue) {
    float scale = Resources.getSystem().getDisplayMetrics().density;
    return (int) (dpValue * scale + 0.5F);
  }

  public static boolean isSupported() {
    return Build.VERSION.SDK_INT >= 19;
  }
}

